define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'diamond/index',
                    table: 'c_club_diamond_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                mobileResponsive: false, //是否自适应移动端
                columns: [
                    [
                        {field: 'clubid', title: __('Clubid'), operate: false},
                        {field: 'clubname', title: __('俱乐部名称'), operate: false},
                        {field: 'clubtype', title: __('类型'), operate: false},
                        {field: 'membernum', title: __('Membernum'), operate: false},
                        {field: 'diamond', title: __('Diamond'), operate: false},
                        {field: 'afternum', title: __('Afternum'), operate: false},
                        {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                    ]
                ],
                onLoadSuccess: function (data) {
//					$("#statistics").html(
//							'<a class="btn btn-danger">剩余房卡：' + data.statistics.diamond + '</a>&nbsp;'
//							+ '<a class="btn btn-success">补充次数：' + data.total + '</a>&nbsp;' 
//							+ '<a class="btn btn-info">补充总额：' + data.statistics.count_diamond + '</a>&nbsp;' 
//							);
//                	$("#statistics").show();
                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});